<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>协会概况--->详情</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${ctxPath}/static/manage/css/x-admin.css" media="all">
    <link rel="stylesheet" href="${ctxPath}/static/manage/layui/css/layui.css" media="all">
    <script src="${ctxPath}/static/manage/js/jquery.js"></script>
    <script type="text/javascript" src="${ctxPath}/static/manage/layui/layui.js"></script>
    <script src="${ctxPath}/static/manage/js/x-layui.js" charset="utf-8"></script>
</head>
<body>
<form class="layui-form" id="formAdd">
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="x-red">*</span>药品名称</label>
        <div class="layui-input-inline">
            <input type="text" onblur="if(this.value.replace(/^ +| +$/g,'')=='')alert('不能为空!')" id="name" name="name" class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="x-red">*</span>作用</label>
        <div class="layui-input-inline">
            <input type="text" onblur="if(this.value.replace(/^ +| +$/g,'')=='')alert('不能为空!')" id="action" name="action" class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">药品类型</label>
        <div class="layui-input-block">
            <select id="typeName" name="typeId" >
                <option value=""></option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="x-red">*</span>购买时间</label>
        <div class="layui-input-inline">
            <input type="date"   placeholder="请输入日期" id="buytime" name="buytime" class="layui-input" />
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><span class="x-red">*</span>售出时间</label>
        <div class="layui-input-inline">
            <input type="date"  placeholder="请输入日期" id="selltime" name="selltime" class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="x-red">*</span>库存</label>
        <div class="layui-input-inline">
            <input type="text" onblur="if(this.value.replace(/^ +| +$/g,'')=='')alert('不能为空!')"id="stock" name="stock" class="layui-input" />
        </div>
    </div>
    <button class="layui-btn" type="button"  lay-filter="add" lay-submit="">添加</button>
    <button class="layui-btn" type="button"   lay-filter="closeBtn" lay-submit="">取消</button>
</form>
<script type="text/javascript">
    layui.use(['form','layer','upload'], function(){
        var $ = layui.$, form = layui.form, upload = layui.upload, layer = layui.layer;
        // 监听提交
        form.on('submit(add)', function(data){
            $.post(
                "addYaopin",
                data.field,
                function(res){
                    console.log(res);
                    window.parent.location.reload();
                },"text"
            )
            alert("添加成功");
            return false;
        })
        //取消按钮
        form.on("submit(closeBtn)",function (data) {
            window.parent.location.reload();
        })
        $(function (){

            $.ajax({
                url: '/manage/drugsType/selectType',
                type: 'post',
                data: {},
                dataType: 'json',
                success: function (res) {
                    if (res.length > 0) {
                        for (var i = 0; i < res.length; i++) {
                          $("#typeName").append("<option value='" + res[i].id + "'>" + res[i].typeName + "</option>");
                            form.render('select');
                        }
                    }
                }
            })
        })
    });
</script>
</body>
</html>
